<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TalkJS forward message example</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- minified snippet to load TalkJS without delaying your page -->
    <script>
        (function(t,a,l,k,j,s){
        s=a.createElement('script');s.async=1;s.src='https://cdn.talkjs.com/talk.js';a.head.appendChild(s)
        ;k=t.Promise;t.Talk={v:3,ready:{then:function(f){if(k)return new k(function(r,e){l.push([f,r,e])});l
        .push([f])},catch:function(){return k&&new k()},c:l}};})(window,document,[]);
        </script>
</head>
<body>
    <main class="flex flex-col items-center">
        <h1 class="text-2xl font-bold mt-8">TalkJS forward message example</h1>
        <!-- container element in which TalkJS will display a chat UI -->
        <div id='talkjs-container' style='width: 90%; margin: 30px; height: 500px'>
            <i>Loading chat...</i>
        </div>

    <!-- Conversation select modal -->
    <section id="forwardModal" tabindex="-1" 
    class="hidden fixed inset-0 z-50 flex items-center justify-center w-full h-full" aria-labelledby="modalTitle">

    <!-- Backdrop shadow -->
    <div class="fixed inset-0 bg-black opacity-30"></div>

    <!-- Modal content wrapper -->
    <div class="relative p-4 w-full max-w-md max-h-full">
        <div class="relative bg-white rounded-lg shadow">
            <!-- Modal header -->
            <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t">
                <h2 id="modalTitle" class="text-lg font-semibold text-gray-900">Forward to ...</h2>
                <button type="button" onclick="closeModal()"
                    class="text-gray-400 bg-transparent hover:bg-white-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center"
                    aria-label="Close forwarding modal"
                    data-modal-toggle="forwardModal">
                    <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
                        viewBox="0 0 14 14">
                        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
                    </svg>
                    <span class="sr-only">Close</span>
                </button>
            </div>
            <!-- Modal body -->
            <form class="p-4 md:p-5" onsubmit="forwardMessage(event)">
                <div class="grid gap-4 mb-4 grid-cols-2">
                    <div class="col-span-2">
                        <div id="conversationList"
                            class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 overflow-y-auto h-48">
                            <!-- Conversations are added here dynamically -->
                        </div>
                    </div>
                </div>
                <button type="submit"
                    class="w-full text-white inline-flex items-center bg-blue-600 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">
                    Forward
                </button>
            </form>
        </div>
    </div>
    </section>

    </main>
    <script src="script.js"></script> 
</body>